package com.dyson.config;

import com.dyson.entity.Info;
import com.dyson.service.MyService;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Author: Wy
 * @Email: DysonWy@foxMail.com
 * @Time: 2020/5/6 11:41
 * @Description:
 */
@Configuration
/**
 * 类路径中必须有MyService 这个类时,才进行配置
 */
@ConditionalOnClass(MyService.class)
/**
 * 开启对@ConfigurationProperties注解支持,
 */
@EnableConfigurationProperties(MyService.class)
public class AutoConfig {


    @Bean
    @ConditionalOnMissingBean
    public Info info(MyService service) {
        service.getKey();
        service.getValue();
        service.getArray();
        return new Info();
    }
}
